#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#include <stdlib.h>
#include <string.h>
#include "personne.h"


void on_button1_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
	Personne P;
	char chemin[] = "personne.txt";

	GtkWidget *entry1;
	GtkWidget *entry2;
	GtkWidget *entry3;

entry1 = lookup_widget(objet_graphique,"entry1");
entry2 = lookup_widget(objet_graphique,"entry2");
entry3 = lookup_widget(objet_graphique,"entry3");

strcpy(P.nom,gtk_entry_get_text(GTK_ENTRY(entry1)));
strcpy(P.prenom,gtk_entry_get_text(GTK_ENTRY(entry2)));
P.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry3)));

enregistrer_personne(chemin,P);

}


void on_button2_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
	Personne P;
	char chemin[] = "personne.txt";
	char Buf0[50] = "Nom: ";
	char Buf1[50] = "PRENOM: ";
	char Buf2[50] = "AGE: ";
	
	GtkWidget* label5;

label5= lookup_widget(objet_graphique,"label5");

lire_personne(chemin,&P);

sprintf(Buf0,"%s %s \n\n %s %s \n\n %s %d \n\n",Buf0,P.nom,Buf1,P.prenom,Buf2,P.age);

gtk_label_set_text(GTK_LABEL(label5),Buf0);


}

